class Solution {
public:
    int minimumSum(int n, int k)
    {
        int x = min(n, k / 2);
        int ans = 0;
        for (int i = 1; i <= x; i++) ans += i;
        if (x == n) return ans;
        for (int i = x + 1; i <= n; i++)
            ans += k + i - x - 1;
        return ans;
    }
};